package com.wunu.zn.api.appliance.action;


import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.gson.Gson;
import com.wunu.zn.api.appliance.service.ActivityMqService;

import common.AppConst;
import common.support.MobileParam;

@Controller
@RequestMapping("/d/ppmhtv")
public class PpmHtvJsmController {
	@Autowired
	private ActivityMqService activityMqService;	
	
	@RequestMapping("/setUp")
	@ResponseBody
    public String set(MobileParam param) {
      Map<String, Object> map = new HashMap<String, Object>();
	  String cname = param.getPara("devId"," HX_89860429161891342575");
	  String model = param.getPara("model","0001");
	  Integer val = param.getParaToInt("fVal");
	  String onOroff = "0000";
	  if(val==1){
		  onOroff ="0001";
	  }
	  StringBuffer bs = new StringBuffer();
	  bs.append(AppConst.CONTEXT_PATH).append(" ").append(cname).append(",").append(model).append(",").append(onOroff);
	  String result = activityMqService.sendMessage(bs.toString(), cname);
       if(result.equals("0")){
		map.put("code", 200);
   		return new Gson().toJson(map); 
       }else{
   		map.put("code", 300);
   		return new Gson().toJson(map); 
       }
    }
	
    
}
